<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<head>
    <th:block th:include="include :: header('借款列表')" />
    <link rel="stylesheet" href="../../../../../../../../../../../../css/navigation.css">
</head>
<body class="gray-bg">
<div class="navigation visible-xs-block">
    <ol class="breadcrumb">
        <span> > </span>
        <li><a href="#" onclick="gomain()">主页</a></li>
        <li style="color: black">借款</li>
    </ol>
    <div class="aLine"></div>
</div>
     <div class="container-div">
        <div class="row">
            <div class="col-sm-12 search-collapse">
                <form id="formId">
                    <div class="select-list">
                        <ul>
                            <li>
                                <label>借款类型：</label>
                                <select id="bStatus" name="bStatus" th:with="type=${@dict.getType('borrowing_status')}">
                                    <option value="">所有</option>
                                    <option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}">
                                </select>
                            </li>
                            <li>
                                <label style="width: 100px">借款申请人：</label>
                                <input type="text" name="bApplicant"/>
                            </li>
                            <li class="select-time">
                                <label>借款时间：</label>
                                <input type="text" class="time-input" id="startTime" placeholder="开始时间" name="params[beginBTime]"/>
                                <span>-</span>
                                <input type="text" class="time-input" id="endTime" placeholder="结束时间" name="params[endBTime]"/>
                            </li>
                            <li>
                                <a class="btn btn-primary btn-rounded btn-sm" onclick="$.table.search()"><i class="fa fa-search"></i>&nbsp;搜索</a>
                                <a class="btn btn-warning btn-rounded btn-sm" onclick="$.form.reset()"><i class="fa fa-refresh"></i>&nbsp;重置</a>
                            </li>
                        </ul>
                    </div>
                </form>
            </div>

            <div class="btn-group-sm" id="toolbar" role="group">
                <a class="btn btn-warning" onclick="$.table.exportExcel()" shiro:hasPermission="ruoyi:amount:export">
                    <i class="fa fa-download"></i> 导出
                </a>
            </div>
            <div class="col-sm-12 select-table table-striped">
                <table id="bootstrap-table"></table>
            </div>
        </div>
    </div>
    <th:block th:include="include :: footer" />
    <script src="../../../../../../../../../../../../js/breadcrumb.js"></script>
    <script th:inline="javascript">
        var editFlag = [[${@permission.hasPermi('ruoyi:amount:edit')}]];
        var removeFlag = [[${@permission.hasPermi('ruoyi:amount:remove')}]];
        var prefix = ctx + "ruoyi/amountmoney";
        var bStatus = [[${@dict.getType('borrowing_status')}]];
        var bType = [[${@dict.getType('borrowing_type')}]];

        $(function() {
            var options = {
                url: prefix + "/list",
                showFooter:true,
                exportUrl: prefix + "/export",
                showColumns: false,
                sortName: 'bTime',
                sortOrder: 'desc',
                modalName: "借款支出",
                columns: [
                {
                    field: 'bId', 
                    title: '借款id',
                    visible: false
                },
                    {
                        field: 'bApplicant',
                        title: '借款申请人'
                    },
                {
                    field: 'bStatus', 
                    title: '借款类型',
                    formatter: function(value, row, index) {
                        return $.table.selectDictLabel(bStatus, value);
                    }
                },
                    {
                        field: 'bCause',
                        title: '借款原因'
                    },
                    {
                        // field: 'bAmount',
                        title: '借款金额',
                        formatter: function (value, row, index) {
                            var bAmount = [];
                            bAmount.push('￥'+row.bAmount)
                            return bAmount.join('');
                        },
                        footerFormatter: function(value){
                            var sum = 0;
                            for (var i in value) {
                                sum += parseFloat(value[i].bAmount)
                            }
                            return "总借款: ￥"+sum;
                        }
                    },
                {
                    field: 'bTime',
                    title: '借款时间',
                    sortable: true
                },

                {
                    field: 'bType',
                    title: '审批状态',
                    align: 'center',
                    formatter: function(value, row, index) {
                        return $.table.selectDictLabel(bType, value);
                    }
                }]
            };
            $.table.init(options);
        });

    </script>
</body>
</html>